<!-- 巡检信息录入 -->
<template>
	<div style="width: 100%; max-width: 65rem; margin: 1rem auto">
		<h2 style="color: red; text-align: center; padding: 0.5rem">{{ $t('message.checkNewsEnter.pageCheckEnter') }}</h2>

		<div>
			<table>
				<tbody>
					<tr>
						<td class="label">{{ $t('message.deviceCheck.pageCheckName') }}</td>
						<td>{{ name }}</td>
						<td class="label">{{ $t('message.deviceCheck.pageCheckTime') }}</td>
						<td colspan="3">
							<input type="text" v-model="formData.inspectTime" />
						</td>
					</tr>

					<!-- 设备相关信息 -->
					<tr>
						<td class="label">{{ $t('message.deviceCheck.pageDeviceType') }}</td>
						<td><input type="text" v-model="formData.deviceType" /></td>
						<td class="label">{{ $t('message.deviceCheck.pageBelongStation') }}</td>
						<td><input type="text" v-model="formData.powerStation" /></td>
						<td class="label">{{ $t('message.deviceCheck.pageBelongDevice') }}</td>
						<td><input type="text" v-model="formData.equipment" /></td>
					</tr>

					<!-- 检查项目 -->
					<tr>
						<td class="label">{{ $t('message.checkNewsEnter.pageCheckProject') }}:</td>
						<td colspan="10">
							<textarea v-model="formData.checkItems" rows="6" cols="100"></textarea>
						</td>
					</tr>

					<!-- 巡检状态 -->
					<tr>
						<td class="label">{{ $t('message.deviceCheck.pageCheckStatus') }}:</td>
						<td colspan="10">
							<el-radio-group v-model="formData.inspectionStatus">
								<el-radio :value="'normal'">{{ $t('message.checkNewsEnter.pageNormal') }}</el-radio>
								<el-radio :value="'abnormal'">{{ $t('message.checkNewsEnter.pageAbnormal') }}</el-radio>
							</el-radio-group>
						</td>
					</tr>

					<!-- 异常情况 -->
					<tr>
						<td class="label">{{ $t('message.checkNewsEnter.pageSituation') }}:</td>
						<td colspan="10">
							<textarea v-model="formData.abnormality" rows="6" cols="100"></textarea>
						</td>
					</tr>

					<!-- 现场图片上传 -->
					<tr>
						<td class="label">{{ $t('message.checkNewsEnter.pageScenePhotos') }}:</td>
						<td colspan="10"><upload></upload></td>
					</tr>

					<!-- 备注 -->
					<tr>
						<td class="label">{{ $t('message.deviceCheck.pageNotes') }}:</td>
						<td colspan="10">
							<textarea v-model="formData.remarks" rows="6" cols="100"></textarea>
						</td>
					</tr>
				</tbody>
			</table>
		</div>

		<div class="form-actions">
			<el-button type="primary" @click="submitForm">{{ $t('message.checkNewsEnter.pageSubmitForm') }}</el-button>
			<el-button @click="resetForm">{{ $t('message.checkNewsEnter.pageResetForm') }}</el-button>
		</div>
	</div>
</template>

<script lang="ts">
import { defineComponent, reactive, toRefs } from 'vue';

export default defineComponent({
	name: 'InspectionForm',

	setup() {
		const state = reactive({
			name: '测试',
			formData: {
				inspectTime: '',
				deviceType: '',
				powerStation: '',
				equipment: '',
				checkItems: '',
				inspectionStatus: '',
				abnormality: '',
				remarks: '',
			},
		});

		const submitForm = () => {
			console.log('Submitting:', state.formData);
			// 添加处理逻辑
		};

		const resetForm = () => {
			Object.keys(state.formData).forEach((key) => {
				(state.formData as any)[key] = '';
			});
		};

		return {
			...toRefs(state),
			submitForm,
			resetForm,
		};
	},
});
</script>

<style lang="scss" scoped>
.label {
	color: #000;
	text-align: center;
	font-weight: bolder;
}

table {
	width: 100%;
	border-collapse: collapse;
}

td {
	padding: 0.1rem;
	border: 1px solid #000;
}

.form-actions {
	display: flex;
	margin-top: 0.6rem;
	justify-content: center;
}
</style>
